# met modifier key to windoze key
# Mod4 is windows, Mod1 is alt
set $mod Mod4
#set $mod Mod1

#font pango:monospace 8
font pango:DejaVu Sans Mono 8

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

# kill focused window
bindsym $mod+Shift+q kill

####################
#### LAUNCHERS ####
####################

# terminal
bindsym $mod+Return                     exec /usr/bin/xterm

# dmenu
bindsym $mod+d                          exec dmenu_run

# ranger
bindsym $mod+r                          exec /usr/bin/xterm -e ranger

# thunderbird
bindsym $mod+t                          exec /usr/bin/thunderbird

# browser
# set $browser "firejail brave-browser --incognito"
# set $browser "firejail firefox"
set $browser "firejail brave-browser"
bindsym $mod+w                          exec $browser

# emacs
bindsym $mod+e                          exec /usr/bin/emacs

# vim
bindsym $mod+Control+v                  exec /usr/bin/xterm -e vim

# notes in vim
bindsym $mod+n                          exec /usr/bin/xterm -e vim ~/notes.md

# neomutt
bindsym $mod+m                          exec /usr/bin/xterm -e neomutt

# kalendar
bindsym $mod+p                          exec ~/source_packages/kalendar-master/src/Kalendar

# run display select script
bindsym $mod+F5                         exec --no-startup-id ~/config_files/dmenu_scripts/display_select.sh

# take a screenshot of selection with scrot
bindsym --release Print exec scrot '%T_%d-%m-%Y'.png -s -e 'mv -n $f ~/screenshots/'
# take a screenshot of screen with scrot
bindsym $mod+Print exec scrot '%T_%d-%m-%Y'.png -e 'mv -n $f ~/screenshots/'

####################
## END LAUNCHERS ###
####################


####################
### i3 CONTROLS ####
####################

# change focus
bindsym $mod+h focus left
bindsym $mod+j focus down
bindsym $mod+k focus up
bindsym $mod+l focus right

# move focused window
bindsym $mod+Shift+h move left
bindsym $mod+Shift+j move down
bindsym $mod+Shift+k move up
bindsym $mod+Shift+l move right

#rezize windows
bindsym $mod+Control+l resize grow width 10 px or 10 ppt
bindsym $mod+Control+h resize shrink width 10 px or 10 ppt
bindsym $mod+Control+k resize grow height 10 px or 10 ppt
bindsym $mod+Control+j resize shrink height 10 px or 10 ppt

# split in horizontal orientation
bindsym $mod+z split h

# split in vertical orientation
bindsym $mod+v split v

# toggle fullscreen mode for the focused container
bindsym $mod+f fullscreen toggle

# change container layout (stacked, tabbed, toggle split)
bindsym $mod+s layout stacking
# bindsym $mod+t layout tabbed
# bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+a focus parent

# focus the child container
#bindsym $mod+d focus child

# switch to workspace
bindsym $mod+1 workspace number 1
bindsym $mod+2 workspace number 2
bindsym $mod+3 workspace number 3
bindsym $mod+4 workspace number 4
bindsym $mod+5 workspace number 5
bindsym $mod+6 workspace number 6
bindsym $mod+7 workspace number 7
bindsym $mod+8 workspace number 8
bindsym $mod+9 workspace number 9
bindsym $mod+0 workspace number 10

#
bindsym $mod+Tab workspace next
bindsym $mod+Shift+Tab workspace prev

# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace 1
bindsym $mod+Shift+2 move container to workspace 2
bindsym $mod+Shift+3 move container to workspace 3
bindsym $mod+Shift+4 move container to workspace 4
bindsym $mod+Shift+5 move container to workspace 5
bindsym $mod+Shift+6 move container to workspace 6
bindsym $mod+Shift+7 move container to workspace 7
bindsym $mod+Shift+8 move container to workspace 8
bindsym $mod+Shift+9 move container to workspace 9
bindsym $mod+Shift+0 move container to workspace 10

# reload the configuration file
#bindsym $mod+Control+c reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+r restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"

# convenenience shortcut for suspend
bindsym $mod+Shift+x exec systemctl suspend

# increase /decrease size of gaps
# tips and inspiration thanks to lukesmith.xyz's dotfiles
# bindsym $mod+g  gaps inner current plus 5
# bindsym $mod+shift+G  gaps inner current minus 5

####################
# end i3 CONTROLS  #
####################

# for physical machine
# manually map X86MonBrightnessUp and Down keys
bindsym XF86MonBrightnessUp exec xbacklight -inc 20
bindsym XF86MonBrightnessDown exec xbacklight -dec 20

# Make the currently focused window a scratchpad
bindsym $mod+Shift+minus move scratchpad

# Show the first scratchpad window
bindsym $mod+minus scratchpad show


# kalendar scratchpad
#
for_window [title="kalendar"] floating enable
for_window [title="kalendar"] move scratchpad

# network manager applet when needed
exec --no-startup-id nm-applet --sm-disable &

# pulseaudio system tray
exec --no-startup-id pasystray

# set bg as last image set with feh
exec --no-startup-id source '/home/km/.fehbg'

# Start i3bar to display a workspace bar (plus the system information i3status)
bar {
    font pango:Deja Vu Sans Mono 16
    position top
    tray_output primary
    # use tray output for network manager or other applets
    status_command i3status
    #mode dock
    mode hide
    modifier $mod
}

# ALSA audio controls

# bindsym XF86AudioRaiseVolume exec --no-startup-id amixer set Master 5+
# bindsym XF86AudioLowerVolume exec --no-startup-id amixer set Master 5-
bindsym $mod+Up exec --no-startup-id amixer set Master 5%+
bindsym $mod+Down exec --no-startup-id amixer set Master 5%-
bindsym XF86AudioMute exec --no-startup-id amixer set Master toggle
bindsym XF86AudioPrev exec --no-startup-id cmus-remote --prev
bindsym XF86AudioNext exec --no-startup-id cmus-remote --next
bindsym XF86AudioPlay exec --no-startup-id cmus-remote -u

# PULSEAUDIO controls

#bindcode --release 113 exec --no-startup-id /usr/bin/pulseaudio-ctl mute
#bindsym $mod+Up exec --no-startup-id /usr/bin/pulseaudio-ctl up
#bindsym $mod+Down exec --no-startup-id /usr/bin/pulseaudio-ctl down


########################################
####### External Programs to Load #####
########################################

# compton for compositing
# exec --no-startup-id compton --config ~/.config/compton.conf -bc &

#bindsym $mod+control+t exec --no-startup-id /usr/bin/pulseaudio-ctl down

# title bars for apps, pixel 0 = for no title; normal = basic title bar
# default_border normal  # show titlebars
new_window pixel 1
# default_border pixel 1


#for_window [class="^.*"] border pixel 0
# i3 upstream (not gaps atm, has default_border to replace new_window)

# make border and split indicator around windows orange (ffa500), other vals are default
client.focused          #4c7899 #285577 #ffffff #ffa500   #ffa500

# hide borders when only a single window open
hide_edge_borders smart

#i3 gaps settings
# gaps inner 0
# gaps outer 0
#
################################################################################
# Deprecated Settings
################################################################################

# for host machine, use named workspaces
#bindsym $mod+Shift+1 move container to workspace 1:virt-m
#bindsym $mod+Shift+2 move container to workspace 2:mail
#bindsym $mod+Shift+3 move container to workspace 3:dev
#bindsym $mod+Shift+4 move container to workspace 4:ent
#
# # move focused window
# bindsym $mod+u move left 40px
# bindsym $mod+i move down 40px
# bindsym $mod+o move up 40px
# bindsym $mod+p move right 40px
#
#####################
# FETCHMAIL SCRATCH #
#####################

#for_window [title="fetch"] floating enable
#for_window [title="fetch"] resize set 1000 800
#for_window [title="fetch"] move scratchpad
#for_window [title="fetch"] border pixel 20

# set up both fetchmail scratchpad
#bindsym $mod+Control+m [title="fetch"] exec --no-startup-id xterm -xrm "xterm*allowTitleOps: false" -T "fetch" -e 'cd ~/mail_configs && sh cryptscript.sh';  [title="fetch"]scratchpad show; [title="fetch"] move position center

####################
#### end fetch #####
####################


####################
# CALCURSE SCRATCH #
####################

# Run a calcurse weekly view window scratchpad
# and a regular view scratchpad
# They are accessed via different key bindings
# for_window [title="calweek"] floating enable
# for_window [title="calweek"] resize set 600 1000
# for_window [title="calweek"] move scratchpad
# for_window [title="calweek"] border pixel 20
#
# for_window [title="calreg"] floating enable
# for_window [title="calreg"] resize set 1200 800
# for_window [title="calreg"] move scratchpad
# for_window [title="calreg"] border pixel 20

# set up both calcurse scratchpads
# bindsym $mod+Control+c [title="calweek"] exec --no-startup-id xterm -xrm "xterm*allowTitleOps: false" -T "calweek" -e 'echo -e "Appointments for the next 7 days:\n (today is `date`)\n" > ~/tempi && calcurse -d 7 >> ~/tempi && less ~/tempi';  [title="calreg"] exec --no-startup-id xterm -xrm "xterm*allowTitleOps: false" -T "calreg" -e calcurse

# nav to the calcurse scratchpads
# bindsym $mod+Shift+c [title="calweek"]scratchpad show; [title="calweek"]move position center
# bindsym $mod+c [title="calreg"]scratchpad show; [title="calreg"]move position center

####################
### end calcurse ###
####################
